<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>sys::Service</title>
  <meta http-equiv='Content-type' content='text/html;charset=UTF-8' />
  <link rel='stylesheet' type='text/css' href='../style.css'/>
</head>
<body>
<p>
  <a href='../index.html'>
    <img src='../logo.png' alt='Sedona'/>
  </a>
</p>
<div class='nav'>
  <a href='../index.html'>Index</a> |
  <a href='../api.html'>Kits</a> |
  <a href='index.html'>sys</a>
</div>
<h1 class='title'>sys::Service</h1>
<hr/>
<pre class='inheritance'><a href='../sys/Obj.html'>sys::Obj</a>
  <a href='../sys/Virtual.html'>sys::Virtual</a>
    <a href='../sys/Component.html'>sys::Component</a>
      sys::Service
</pre>
<em>public </em> class <b>Service</b>  [niagaraIcon=&#x22;module://icons/x16/gears.png&#x22;]<br>
<hr/>
<p>Service is a component which gets to execute background&#xa;work between execution cycles.  Services are also designed&#xa;to be looked up by type within an application.</p>
<hr/>
<dl>
<dt>nextService</dt>
<dd><p class='sig'><code><em><em>public</em> </em><b><a href='../sys/Service.html'>Service</a> nextService</b>

</code></p>
<p>Used for App&#x27;s linked list of services</p>
</dd>
<dt>onHibernate</dt>
<dd><p class='sig'><code><em><em>public</em> <em>virtual</em> </em><b>void onHibernate()</b>

</code></p>
<p>Callback when device is entering low-power sleep mode.</p>
</dd>
<dt>onUnhibernate</dt>
<dd><p class='sig'><code><em><em>public</em> <em>virtual</em> </em><b>void onUnhibernate()</b>

</code></p>
<p>Callback when device is exiting low-power sleep mode.</p>
</dd>
<dt>work</dt>
<dd><p class='sig'><code><em><em>public</em> <em>virtual</em> </em><b>bool work()</b>

</code></p>
<p>Perform a chunk of background work.  Return true&#xa;if there is pending work or false if the service is&#xa;done working this cycle.</p>
<p>A service should be designed to function correctly no&#xa;matter how many times work is called per execution cycle.&#xa;Returning false is not a guarantee that work will not be&#xa;called again in a given execution cycle; rather, it is&#xa;a hint to the App execution engine that this service does&#xa;not have any more work to do.</p>
<p>If you only want to do work once per execution cycle, you should consider:</p>
<p>1) Moving your work into the execute() callback. execute() will only be&#xa;called once per execution cycle.</p>
<p>2) Set a &#x22;newCycle&#x22; flag in your execute() method and unset it after&#xa;doing one work cycle.  Only do your work if the newCycle flag is set.</p>
</dd>
</dl>
<div class='nav'>
  <a href='../index.html'>Index</a> |
  <a href='../api.html'>Kits</a> |
  <a href='index.html'>sys</a>
</div>
<div class='copyright'>Copyright &#169; 2009, Tridium, Inc.</div>
</body>
</html>
